/*
 * @Author: szx
 * @Date: 2022-02-16 12:07:09
 * @LastEditTime: 2022-02-16 12:15:09
 * @Description:
 * @FilePath: \leetcode\1300-1399\1380\1380.js
 */
/**
 * @param {number[][]} matrix
 * @return {number[]}
 */
var luckyNumbers = function (matrix) {
    const m = matrix.length;
    const n = matrix[0].length;
    const row = new Array(m).fill(Number.MAX_SAFE_INTEGER);
    const col = new Array(n).fill(0);
    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            row[i] = Math.min(row[i], matrix[i][j]);
            col[j] = Math.max(col[j], matrix[i][j]);
        }
    }
    let res = [];
    for (let i = 0; i < n; i++) {
        if (row.indexOf(col[i]) != -1) res.push(col[i]);
    }
    return res;
};
